<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/commons/taglib.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
	<div class="easyui-panel">
		<div style="padding: 10px">
			<form id="frmProduct">
				<input type="hidden" name="product.id" value="${product.id}" />
				<table width="100%">
					<tr>
						<td width="25%" align="right"><span>产品编码：</span></td>
						<td width="75%" align="left"><input class="easyui-validatebox" type="text" name="product.code"
							data-options="required:true" value="${product.code}" style="width: 98%" /></td>
					</tr>
					<tr>
						<td><span>产品名称：</span></td>
						<td><input class="easyui-validatebox" type="text" name="product.name" data-options="required:true"
							value="${product.name}" style="width: 98%" /></td>
					</tr>
					<tr>
						<td><span>所属商家：</span></td>
						<td><s:select list="providers" listKey="id" listValue="name" name="product.providerId" value="product.providerId"
								theme="simple" cssStyle="width: 98%" emptyOption="true" /></td>
					</tr>
					<tr>
						<td><span>品牌：</span></td>
						<td><input class="easyui-validatebox" type="text" name="product.model" data-options="required:true"
							value="${product.model}" style="width: 98%" /></td>
					</tr>
					<tr>
						<td><span>单价：</span></td>
						<td><input class="easyui-validatebox" type="text" name="product.price" data-options="required:true"
							value="${product.price}" style="width: 98%" /></td>
					</tr>
					<tr>
						<td><span>描述：</span></td>
						<td><textarea rows="3" name="product.description" style="width: 98%">${product.description}</textarea></td>
					</tr>
				</table>
			</form>
		</div>
	</div>

	<div style="text-align: center; padding: 5px">
		<a href="javascript:void(0)" class="easyui-linkbutton" onclick="submitfrmProduct()">保存</a> <a href="javascript:void(0)"
			class="easyui-linkbutton" onclick="closewinProduct()">关闭</a>
	</div>

	<script type="text/javascript">
		function submitfrmProduct() {
			var issubmit = true;
			$("input.easyui-validatebox").each(function(obj) {
				if ($(this).validatebox("isValid") == false) {
					issubmit = false;
				}
			});
			if (issubmit) {
				var params = $("#frmProduct").serialize();
				$.ajax({
					url : "${path}/business/product/save.do",
					type : "POST",
					data : params,
					dataType : "json",
					success : function(data) {
						if (null != data.message) {
							$.messager.alert("提示信息", data.message);
						} else {
							$.messager.alert("提示信息", "数据保存成功！");
						}
					}
				});
			}
		}
	</script>
</body>
</html>